package com.itheima.homework;

public class Demo9 {
    public static void main(String[] args) {
        int arr[] = {8,9,14,20,24,30,5};

       // wei(arr);
        wei2(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }

        }

    public static void wei(int arr[]){
        int temp = arr[0];
        arr[0] = arr[arr.length-1];
        arr[arr.length-1] = temp;
    }

    public static void wei2(int[] arr){
        arr[0] = arr[0] ^ arr[arr.length - 1];
        arr[arr.length-1] = arr[arr.length - 1] ^ arr[0];
        arr[0] = arr[arr.length-1] ^ arr[0];
    }


}

